#ifndef _KC_FILE_READER__H_KC_2010_
#define _KC_FILE_READER__H_KC_2010_

#include <fstream>
#include <stdexcept> // std::runtime_error, std::out_of_range

namespace kc_sf
{
	class FileReader
	{
		public:

			FileReader(const std::string &filepath); // throw FileReader::Error
			~FileReader();

			// <start, end)
			std::string read(unsigned int start, unsigned int end); // throws std::out_of_range
			char charAt(unsigned int pos); // throws std::out_of_range
			unsigned int size() const { return fr_file_size; }

			struct Error: public std::runtime_error
			{
				typedef enum { NO_FILE, NO_ACCESS } Type;

				Error(Type _type, const std::string &err)
				: std::runtime_error(err), type(_type)
				{
				}

				Type type;
			};

		private:

			std::ifstream fr_stream; // strumień pliku
			unsigned int fr_file_size; // wielkość pliku w bajtach
	};
}

#endif // _KC_FILE_READER__H_KC_2010_
